package divestoclimb.checklist.data;

import java.util.Date;

public class Check extends Item {
	public static final int STATE_BLANK=0;
	public static final int STATE_CHECKED=1;
	public static final int STATE_SKIPPED=2;
	protected int mState;
	protected Date mStateChangedDate;	// For a checklist field, when the state was last changed
	
	// Getters and setters
	public int getState() { return mState; }
	public void setState(int state) {
		if(mState != state) {
			mState = state;
			mStateChangedDate = new Date();
			mDirty = true;
		}
	}
	/**
	 * Call this when importing data from an external source. No checking/validation
	 * is done.
	 * @param state The state of this check
	 * @param stateChangedDate The date the state was changed
	 */
	public void setState(int state, Date stateChangedDate) {
		mState = state;
		mStateChangedDate = stateChangedDate;
	}
	public Date getStateChangedDate() { return mStateChangedDate; }
	
	// Constructors
	public Check(int container_type, long container_id) {
		super(container_type, container_id);
	}

	// This constructor is called when building within a Template, since Templates
	// don't care about state.
	public Check(int container_type, long container_id, long id, int order, String text) {
		super(container_type, container_id, id, order, text);
		mState = STATE_BLANK;
		mDirty=false;
	}
	
	// This constructor is used when building within a Checklist. Includes all
	// fields
	public Check(int container_type, long container_id, long id, int order, String text, int state, Date when_state_changed) {
		super(container_type, container_id, id, order, text);
		mState = state;
		mStateChangedDate = when_state_changed;
		mDirty=false;
	}

}
